package scau.mis4.chanyulin.atm.base.utils;

import javafx.collections.ObservableList;
import javafx.scene.control.TreeItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

/**
 * Created by cyl on 2017/3/27
 * 图形化界面工具类
 */
public class UiUtils {

    /**
     * 通过路径获取图片视图
     * @param path
     */
    public static ImageView getImageView(String path) {
        return new ImageView(new Image(path));
    }

    /**
     * 通过路径获取图片
     * @param path
     */
    public static Image getImage(String path) {
        return new Image(path);
    }

    /**
     * 收缩所有子节点
     * @param father 父节点
     */
    public static void closeAllChildren(TreeItem father) {
        ObservableList<TreeItem> children = father.getChildren();
        if (children.size() == 0)
            return;
        for (TreeItem item : children) {
            item.setExpanded(false);
            closeAllChildren(item);
        }
    }

}
